WTL Controls
Back to the WTL Controls Home Page.
BIS_WTL_CONTROLS::CStatusBarPlus Class Reference

A CMultiPaneStatusBarCtrl descendant with a child CProgressBarCtrl that can be embedded in a user-selected pane. Default configuration creates a status bar with three panes, with the progress bar embedded in the third. Default pane IDs are ID_DEFAULT_PANE (defined as 0), 1 and 2. More...

#include <StatusBarPlus.h>

Inheritance diagram for BIS_WTL_CONTROLS::CStatusBarPlus:

Public Member Functions

 CStatusBarPlus () noexcept
 
virtual ~CStatusBarPlus ()
 
virtual BOOL SubclassStatusBar (HWND hFrameWnd, UINT ProgressBarCtlID, UINT style_flags=0)
 SubclassStatusBar subclasses a pre-existing status bar and creates a default 3 panes with a progress bar embedded in the third. Override to customize/alter this behavior. More...
 
virtual void UnSubclassStatusBar ()
 Release the status bar and destroy the embedded progress bar control. More...
 
CProgressBarCtrl & ProgressBar ()
 Returns a reference to the embedded CProgressBarCtrl. More...
 
BOOL SetPaneStyle (int pane_index, UINT flags)
 Valid style flags are 0 (sunken - no longer works on Win10), SBT_NOBORDERS, SBT_OWNERDRAW, SBT_POPOUT, SBT_RTLREADING and SBT_NOTABPARSING. Specify only one per pane; see the MSDN documentation for the SB_SETTEXT message for more detail. More...
 
void SetProgressBarMargin (int margin)
 Defines the margin around the embedded CProgressBarCtrl, within the pane client area. Make sure not to make this value too big. More...
 
int GetProgressBarMargin () const
 Default : 2. More...
 
void SetProgressBarPane (int pane_index)
 Select the pane to contain the embedded CProgressBarCtrl. More...
 
int GetProgressBarPane () const
 Default : 2. More...
 

Protected Attributes

CProgressBarCtrl m_ProgressBar
 
int m_iProgressBarMargin
 
int m_iProgressBarPane
 

Detailed Description

A CMultiPaneStatusBarCtrl descendant with a child CProgressBarCtrl that can be embedded in a user-selected pane. Default configuration creates a status bar with three panes, with the progress bar embedded in the third. Default pane IDs are ID_DEFAULT_PANE (defined as 0), 1 and 2.

A typical setup snippet is shown below. It configures a 3-pane status bar with the center pane owner-drawn, uses UISetText to modify text in the right-most pane, while leaving the left pane with the default pane functionality. The sample also loads an icon into the right pane, and demonstrates a little trick with tab characters in the pane text - if the text is preceded by one tab, it'll be centered. If it's preceded by two tabs, it'll be right justified. Also note that modifying text with UISetText as demonstrated takes a couple of preliminary steps. First, the pane has to be added to the UpdateUI map. This is accomplished by including it in the map declarations in the client application's mainframe header file:

UPDATE_ELEMENT(2, UPDUI_STATUSBAR)

The first parameter is the index of the pane to be updated, NOT it's ID. (Although, in this case, the defaults are the same.) And second, the status bar itself has to be added to the update map with the UIAddStatusBar call, as shown below. Failure to do so will prevent the text from being modified. And finally, to actually execute any pending changes, UIUpdateStatusBar() is called from the mainframe OnIdle handler.

CreateSimpleStatusBar();
m_StatusBar.SubclassStatusBar(m_hWndStatusBar, IDC_STATUS_BAR_PROGRESS, 0);
UISetCheck(ID_VIEW_STATUS_BAR, 1);
UIAddStatusBar(m_StatusBar.m_hWnd);
m_StatusBar.SetPaneWidth(1, 250);
m_StatusBar.SetPaneWidth(2, 150);
m_StatusBar.SetProgressBarMargin(3);
m_StatusBar.SetPaneStyle( 1, SBT_OWNERDRAW);
m_StatusBar.ProgressBar().SetStep(1);
m_StatusBar.SetIcon(2, AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR));
UISetText(2, _T("\twizzle"), TRUE);

Calling UnSubclassStatusBar when disposing of the parent window (e.g; in the parent's WM_DESTROY handler) ensures orderly destruction of the embedded CProgressBarCtrl.

NOTE: This implementation plays a little fast and loose with the intended functionality of CStatusBar::SetPanes. The pane IDs passed as an array of integers are meant to be the IDs of strings in the host app's embedded string table resource. The default behavior loads these strings and measures their extent, then sizes the panes as neccessary to accomodate these strings. I've used the integers 1 and 2 as pane IDs, in addition to the framework defined ID_DEFAULT_PANE, which is defined as 0. Unless the string table contains strings with symbols defined as 1 and 2, the attempt to load string resources with these IDs will fail. Failure is silent with no side effects - the panes are given a client width of 0, and nothing worse. Of course, should an app define strings with symbols defined as 1 or 2, the panes will have some non-zero initial size. Either way, they can be sized directly with CStatusBar::SetPaneWidth.

Definition at line 76 of file StatusBarPlus.h.

Constructor & Destructor Documentation

◆ CStatusBarPlus()

BIS_WTL_CONTROLS::CStatusBarPlus::CStatusBarPlus ( )
noexcept

Definition at line 21 of file StatusBarPlus.cpp.

◆ ~CStatusBarPlus()

BIS_WTL_CONTROLS::CStatusBarPlus::~CStatusBarPlus ( )
virtual

Definition at line 27 of file StatusBarPlus.cpp.

Member Function Documentation

◆ SubclassStatusBar()

BOOL BIS_WTL_CONTROLS::CStatusBarPlus::SubclassStatusBar ( HWND  hStatusBar,
UINT  ProgressBarCtlID,
UINT  style_flags = 0 
)
virtual

SubclassStatusBar subclasses a pre-existing status bar and creates a default 3 panes with a progress bar embedded in the third. Override to customize/alter this behavior.

Optional style flags might include PBS_SMOOTH to create a smooth progress fill. (Truth be told, I don't think Win10 supports anything BUT PBS_SMOOTH. It'll work fine with it, but looks the same without it.)

Parameters
hStatusBarThe handle to the basic status bar.
ProgressBarCtlIDThe control ID to assign to the progress bar.
style_flagsAdditional style flags to apply to the progress bar (e.g., PBS_SMOOTH). WS_CHILD and WS_VISIBLE are included by default.
Return values
BOOL/c TRUE if succesful.

Definition at line 47 of file StatusBarPlus.cpp.

◆ UnSubclassStatusBar()

void BIS_WTL_CONTROLS::CStatusBarPlus::UnSubclassStatusBar ( )
virtual

Release the status bar and destroy the embedded progress bar control.

Return values
void

Definition at line 92 of file StatusBarPlus.cpp.

◆ ProgressBar()

CProgressBarCtrl & BIS_WTL_CONTROLS::CStatusBarPlus::ProgressBar ( )

Returns a reference to the embedded CProgressBarCtrl.

Return values
CProgressBarCtrl&

Definition at line 105 of file StatusBarPlus.cpp.

◆ SetPaneStyle()

BOOL BIS_WTL_CONTROLS::CStatusBarPlus::SetPaneStyle ( int  pane_index,
UINT  flags 
)

Valid style flags are 0 (sunken - no longer works on Win10), SBT_NOBORDERS, SBT_OWNERDRAW, SBT_POPOUT, SBT_RTLREADING and SBT_NOTABPARSING. Specify only one per pane; see the MSDN documentation for the SB_SETTEXT message for more detail.

Owner-drawn status bar panels reflect their WM_DRAWITEM messages to the parent frame window (the status bar itself). (No WM_MEASUREITEM messages are sent.) The DRAWITEMSTRUCT CtlID parameter will be set to the control ID associated with the status bar (default is ATL_IDW_STATUS_BAR), and the ItemID will be the pane ID (if the default SubclassStatusBar method is used, they'll be numbered 0~2).

Parameters
pane_indexThe 0-based index of the pane to modify.
flagsThe new style.
Return values
BOOL/c TRUE if succesful.

Definition at line 127 of file StatusBarPlus.cpp.

◆ SetProgressBarMargin()

void BIS_WTL_CONTROLS::CStatusBarPlus::SetProgressBarMargin ( int  margin)

Defines the margin around the embedded CProgressBarCtrl, within the pane client area. Make sure not to make this value too big.

Parameters
marginThe new margin around the progress bar.
Return values
void

Definition at line 168 of file StatusBarPlus.cpp.

◆ GetProgressBarMargin()

int BIS_WTL_CONTROLS::CStatusBarPlus::GetProgressBarMargin ( ) const

Default : 2.

Returns the current margin between the embedded CProgressBarCtrl and the pane containing it.

Return values
intThe current progress bar margin.

Definition at line 181 of file StatusBarPlus.cpp.

◆ SetProgressBarPane()

void BIS_WTL_CONTROLS::CStatusBarPlus::SetProgressBarPane ( int  pane_index)

Select the pane to contain the embedded CProgressBarCtrl.

Parameters
pane_indexThe index of the pane which will contain the embedded CProgressBarCtrl.
Return values
void

Definition at line 197 of file StatusBarPlus.cpp.

◆ GetProgressBarPane()

int BIS_WTL_CONTROLS::CStatusBarPlus::GetProgressBarPane ( ) const

Default : 2.

Returns the current index of the pane containing the embedded CProgressBarCtrl.

Return values
intThe current pane index.

Definition at line 210 of file StatusBarPlus.cpp.

Member Data Documentation

◆ m_ProgressBar

CProgressBarCtrl BIS_WTL_CONTROLS::CStatusBarPlus::m_ProgressBar
protected

Definition at line 106 of file StatusBarPlus.h.

◆ m_iProgressBarMargin

int BIS_WTL_CONTROLS::CStatusBarPlus::m_iProgressBarMargin
protected

Definition at line 107 of file StatusBarPlus.h.

◆ m_iProgressBarPane

int BIS_WTL_CONTROLS::CStatusBarPlus::m_iProgressBarPane
protected

Definition at line 108 of file StatusBarPlus.h.


The documentation for this class was generated from the following files: